﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

using AtletIS.Shared.Data.aDbDataSetTableAdapters;
using AtletIS.Shared.Entities;

namespace AtletIS.Shared.Helpers
{
    public static class StatusHelper
    {
        private static DisciplineListTableAdapter taDisciplineList = new DisciplineListTableAdapter();

        /// <summary>
        ///  Update statusu disciplíny
        /// </summary>
        public static void UpdateStatus(DisciplineListEntity discipline, int newStatus)
        {
            // Update [status] = ukoncena
            DataTable dtDiscipline = DatabaseHelper.GetDisciplineListById(discipline.ID); // taDisciplineList.GetById(discipline.ID);
            if (dtDiscipline.Rows.Count > 0)
            {
                dtDiscipline.Rows[0]["Status"] = newStatus;
                dtDiscipline.Rows[0]["Modified"] = DateTime.Now;

                if (newStatus == 3)
                {
                    dtDiscipline.Rows[0]["RealEndTime"] = DateTime.Now;
                }
                else
                {
                    dtDiscipline.Rows[0]["RealEndTime"] = DBNull.Value;
                }

                taDisciplineList.Update(dtDiscipline.Rows[0]);
            }
        }




    }
}
